'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:SignFootmarkCtrl
 * @description
 * # SignFootmarkCtrl
 * Controller of the jgappApp
 */
angular.module('jgappApp')
  .controller('SignFootmarkCtrl', function (UserInfo,MapService, $scope, PagingService, $location, Util, openApi,localStorageService) {
    var vm = this;
    vm.goIndex = function () {
      $location.path("sign/index").replace();
    }
    vm.checkPoints = function (data) {
      localStorageService.set("markPonits",data.list);
      $location.path("sign/footmarkdetail");
    }
    // 查看签到地点
    vm.showPosition = function (item) {
      $location.path("attendance/show_location/" + item.lat + "/" + item.lng)
    }
    // 选择签到月份
    vm.chooseDate = function () {
      getSignLog()
    };

    var setDate = function () {
      vm.dates = []
      var date = new Date();
      vm.year = date.getFullYear();
      var curMonth = date.getMonth() + 1;
      vm.month = curMonth
      while (curMonth > 0) {
        vm.dates.push(curMonth)
        curMonth--
      }
    }
    vm.goDetail = function (data) {
      $scope.src = openApi.showimg + "?fileName=" + data;
      Util.showFile($scope);
    }
    $scope.closefile = Util.hideFile;
    var getSignLog = function () {
      var param = {};
      param.year = vm.year;
      param.month = vm.month;
      param.limit = 5;
      vm.taskList = new PagingService(openApi.signinLog, param);
    }
    var init = function () {
      setDate();
      getSignLog();
      UserInfo.getUseinfo().then(function(data){
        vm.UserInfo = data;
      });
    };
    init()
  });
